package com.dingwen.treasure.base.annotation;

import com.dingwen.treasure.base.valid.AllowableValuesValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * 自定义 validation 参数校验 允许的值集合
 *
 * @author dingwen
 * @date 2022/06/27
 */
@Documented
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = {AllowableValuesValidator.class})
@Inherited
public @interface AllowableValues {

    /**
     * 提示错误消息
     */
    String message() default "参数值不在合法范围内";

    /**
     * 可选的字符串值
     */
    String[] strValues() default {};

    /**
     * 可选的数字值
     */
    int[] intValues() default {};


    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}
